package com.woniuxy.dudugua.service.impl;

import com.woniuxy.dudugua.entity.Coupon;
import com.woniuxy.dudugua.mapper.CouponMapper;
import com.woniuxy.dudugua.mapper.OrderInfoMapper;
import com.woniuxy.dudugua.mapper.OrderMapper;
import com.woniuxy.dudugua.service.AdminService;
import com.woniuxy.dudugua.util.view.AdminOrderView;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {
    @Resource
    private OrderMapper orderMapper;
    @Resource
    private OrderInfoMapper orderInfoMapper;
    @Resource
    private CouponMapper couponMapper;
    /**
     * 管理员查看所有订单
     * @return
     * @throws Exception
     */
    public List<AdminOrderView> selectAllOrder(Integer index,Integer number) throws Exception {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("index",index);
        map.put("number",number);
        return orderMapper.selectAllOrder(map);
    }

    @Override
    public List<Coupon> selectAllCoupons(Integer index, Integer number) throws Exception {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("index",index);
        map.put("number",number);
        return couponMapper.selectAllCoupon(map);
    }

    public long selectOrderCount() throws Exception {
        long l = orderInfoMapper.countByExample(null);
        return l;
    }

    @Override
    public long selectCouponCount() throws Exception {
        long l = couponMapper.countByExample(null);
        return l;
    }
}
